﻿using System;
using System.Windows.Forms;

namespace SerbinAV.MobileSales.Sales.Views
{
    public partial class DailyVisitView : Form, IDailyVisitsView
    {
        //#region IDailyVisitsForm Members

        public new bool Show()
        {
            base.ShowDialog();
            return true;
        }

        public object DataSource
        {
            set
            {
                bndSourceDailyVisit.DataSource = value;
            }
            get { return dgDailyVisits.DataSource; }
        }

        public object Current
        {
            get { return bndSourceDailyVisit.Current; }
        }

        //public ControlCollection ParentControl {
        //    get
        //    {
        //        return addBuyPointPanel.Controls;
        //    }

        //}

        //public void ShowAddVisitDialog(AddVisitDialog visitDialog)
        //{
        //    visitDialog.Dock = DockStyle.Fill;
        //    addBuyPointPanel.Controls.Add(visitDialog);
        //    //mainPanel.Enabled = false;
        //    addBuyPointPanel.Visible = true;
        //    //addBuyPointPanel.Enabled = true;
        //}

        //public void CloseAddVisitDialog()
        //{
        //    addBuyPointPanel.Visible = false;
        //}

        public event EventHandler<EventArgs> AddVisit;

        public event EventHandler<EventArgs> DeleteVisit;

        public event EventHandler<EventArgs> CreateFromShedule;

        //#endregion

        public DailyVisitView()
        {
            InitializeComponent();
            
            DataGridTextBoxColumn dataColumn;
            DataGridTableStyle ts = new DataGridTableStyle();

            dataColumn = new DataGridTextBoxColumn();
            dataColumn.HeaderText = "Назва торгової точки";
            dataColumn.MappingName = "ByPointName";
            dataColumn.NullText = "";
            dataColumn.Width = 150;
            ts.GridColumnStyles.Add(dataColumn);

            dataColumn = new DataGridTextBoxColumn();
            dataColumn.HeaderText = "Адреса";
            dataColumn.MappingName = "BuyPointAdress";
            dataColumn.NullText = "";
            dataColumn.Width = 200;
            ts.GridColumnStyles.Add(dataColumn);
            ts.MappingName = "Visit";
                //bndSourceDailyVisit.DataSource.GetType().Name;
            dgDailyVisits.TableStyles.Add(ts);

            dgDailyVisits.RowHeadersVisible = false;
            deleteMenuItem.Enabled = false;
            //Cursor.Current = Cursors.Default;

        }

        private void loadMenuItem_Click(object sender, EventArgs e)
        {
            CreateFromShedule(null, null);
        }

        //private void addMenuItem_Click(object sender, EventArgs e)
        //{
        //    Cursor.Current = Cursors.WaitCursor;
        //    AddVisit(null, null);
        //}

        //private void deleteMenuItem_Click(object sender, EventArgs e)
        //{
        //        DeleteVisit(null, null);
        //}

        //private void dailyVisitsDataGrid_CurrentCellChanged(object sender, EventArgs e)
        //{
        //    deleteMenuItem.Enabled = true;
        //    if (dailyVisitsDataGrid.CurrentRowIndex < 0 || ((List<Visit>)dailyVisitsDataGrid.DataSource)[dailyVisitsDataGrid.CurrentRowIndex].IsReadOnly)
        //        deleteMenuItem.Enabled = false;
            
        //}

    }
}